package sun.curriculumschedule;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.johnsun.mytestapp.R;

import java.util.ArrayList;

/**
 * Created by JohnSun on 2016/1/28.
 */
public class LessonScheduleAdapetr extends BaseAdapter {
    private Context context;
    private ArrayList<ShowCurriculum> curriculumList;
    public LessonScheduleAdapetr(Context context,ArrayList<ShowCurriculum> curriculumList){
        this.curriculumList=curriculumList;
        this.context=context;

    }


    @Override
    public int getCount() {
        return  curriculumList.size();
    }

    @Override
    public Object getItem(int position) {
        return curriculumList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
         ViewHolder viewHolder=null;
        if (convertView==null){
            viewHolder=new ViewHolder();
            convertView= LayoutInflater.from(context).inflate(R.layout.lesson_schedule_item, null);
            viewHolder.name= (TextView) convertView.findViewById(R.id.schedule_name);
            convertView.setTag(viewHolder);
        }
       else{
          viewHolder= (ViewHolder) convertView.getTag();
        }

        viewHolder.name.setText(curriculumList.get(position).getMajor());

         return convertView;
    }

   public class  ViewHolder {
        public TextView name;
    }


    public ArrayList<ShowCurriculum> getCurriculumList() {
        return curriculumList;
    }

    public void setCurriculumList(ArrayList<ShowCurriculum> curriculumList) {
        this.curriculumList = curriculumList;
    }
}
